import platform
import time
import numpy as np
import cv2
from bindings import mvsdk_modify as mvsdk
import time

handle_camera=0
timeout_ms =300
mvsdk.Init()
mvsdk.CameraInit_Hawk(handle_camera)
while True:
    #point_raw_data is BYTE*
    tic = time.clock()
    point_raw_data, frame_head = mvsdk.CameraGetImageBuffer(handle_camera, timeout_ms)
    time_consume = (time.clock() - tic)
    print("CameraGetImageBuffer time used :", time_consume)
    # tic = time.clock()
    buf = np.fromstring(point_raw_data.raw, dtype=np.uint8)
    src = cv2.imdecode(buf, flags = cv2.IMREAD_COLOR)
    # time_consume = (time.clock() - tic)
    # print("imdecode time used :", time_consume)
    cv2.imshow('src', src)
    #13, 与3差别不大
    cv2.waitKey(33)